home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / GETMID.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  1KB  |  39 lines

  1. ' GETMID.BAS
  2. ' This program demonstrates the MID$ function.
  3.  
  4. CLS
  5.  
  6. alphabet$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"  ' declare test string
  7.  
  8. PRINT "How many characters (from left to right) in the following"
  9. PRINT "string would you like to display?"
  10. PRINT
  11. PRINT alphabet$                           ' display test string
  12. PRINT
  13.  
  14.     ' get from user number of characters to be displayed
  15. DO  ' loop until number is in proper range (1 through 26)
  16.     INPUT "    Number (1-26):  ", numToDisplay%
  17. LOOP WHILE (numToDisplay% < 1) OR (numToDisplay% > 26)
  18.  
  19. PRINT                                     ' get starting number...
  20. PRINT "What character would you like to start with?"
  21. PRINT
  22.  
  23. DO                                        '   in proper range
  24.     INPUT "    Starting number (1-26):  ", start%
  25. LOOP WHILE (start% < 1) OR (start% > 26)
  26.  
  27. PRINT                                     ' get characters
  28. midChar$ = MID$(alphabet$, start%, numToDisplay%)
  29.  
  30.     ' compare requested characters with actual characters retrieved
  31.     '   and print an appropriate message with string
  32. IF (numToDisplay% = LEN(midChar$)) THEN
  33.     PRINT numToDisplay%; "characters displayed:  "; midChar$
  34. ELSE
  35.     PRINT numToDisplay%; "characters requested,";
  36.     PRINT LEN(midChar$); "displayed:  "; midChar$
  37. END IF
  38.  
  39.